﻿using System;
using System.Web.Mvc;
using Ornament.MemberShip;
using Ornament.Web.Mvc;

namespace Ornament.Web.ModelBinder
{
    public class UserGroupBinder : BaseModelBinder
    {
        protected override object CreateNewObject(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType)
        {
            return new UserGroup(controllerContext.RequestContext.HttpContext.Request["Name"]);
        }
        protected override object RequestId(System.Web.HttpRequestBase request)
        {
            var id = request["Id"];
            if (id == null)
                return null;
            return new Guid(id);
        }
    }
}